package com.atguigu.day17.test04;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author fenge
 */
public class Test04 {
    public static void main(String[] args) {
        ArrayList<Integer> arrayList = new ArrayList<>();
        System.out.println("随机数为:");
        for (int i = 0; i < 30; ) {
            int rand = (int) (Math.random() * 99) + 2;
            if (!arrayList.contains(rand)) {
                arrayList.add(rand);//2,100 100-2+1+0
                i++;
            }
        }
        Iterator iterator = arrayList.iterator();
        for (Integer integer : arrayList) {
            System.out.print(iterator.next().toString()+",");
        }
        System.out.println("\n其中的质数为:");
        for (Integer integer : arrayList) {
            boolean flag = true;
            for (int i = 2; i <= Math.sqrt(integer); i++) {
                if (integer % i == 0)
                    flag = false;
            }
            if (flag)
                System.out.print(integer+",");

        }
//        ArrayList<Integer> ori = new ArrayList<>();
//        ori.add()
    }
}
